#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>


typedef void (*task_t)();

void PrintLog()
{
    std::cout<<"这是一个打印日志的任务"<<std::endl;
}

void DownLoad()
{
    std::cout<<"这是一个下载的任务"<<std::endl;
}

void UpLoad()
{
    std::cout<<"这是一个上传的任务"<<std::endl;
}

class TaskManager
{
public:
    TaskManager() 
    {
        srand((unsigned int)time(NULL));  
    }

    ~TaskManager() {}

    void Register(task_t t)
    {
        _tasks.push_back(t);
    }

    int Code()
    {
        int code=rand()%_tasks.size();
        return code;
    }

    void Execute(int code)
    {
        if(code>=0&&code<_tasks.size())
        {
            _tasks[code]();
        }
    }

private:
    std::vector<task_t> _tasks;
};